/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.fiap.bean;

import java.util.ArrayList;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ValueChangeEvent;


@ManagedBean(name = "eventos")
@SessionScoped

/**
 *
 * @author rm62102
 */
public class EventosBean {

    private ArrayList<String> lista;
    private String campoA;
    private String campoB;
    private ArrayList<String> listaB;

    public EventosBean(){
        lista = new ArrayList<String>();
        lista.add("Abacate");
        lista.add("Beterraba");
        lista.add("Abelha");
        lista.add("Palavra");
        lista.add("Computador");
        lista.add("Arca");
        listaB = new ArrayList<String>();
    }

    public ArrayList<String> getListaB() {
        return listaB;
    }

    public void setListaB(ArrayList<String> listaB) {
        this.listaB = listaB;
    }

    public String getCampoB() {
        return campoB;
    }

    public void setCampoB(String campoB) {
        this.campoB = campoB;
    }


    public String getCampoA() {
        return campoA;
    }

    public void setCampoA(String campoA) {
        this.campoA = campoA;
    }

    public ArrayList<String> getLista() {
        return lista;
    }

    public void setLista(ArrayList<String> lista) {
        this.lista = lista;
    }

    public void campoMudou(ValueChangeEvent e){
        String digitado = e.getNewValue().toString().charAt(0)+"";
        this.listaB.clear();
        this.campoB="";
        for(String tmp : lista){
            if(tmp.startsWith(digitado)){
                listaB.add(tmp);
            }
        }
    }

}
